/*
 * FlvMediaMuxer.h
 *
 *  Created on: 2020年6月6日
 *      Author: chuanjiang.zh
 */

#ifndef FLVMEDIAMUXER_H_
#define FLVMEDIAMUXER_H_

#include "UMediaMuxer.h"
#include "TimeShift.h"


class FlvMediaMuxerPrivate;


class DLLEXPORT FlvMediaMuxer: public UMediaMuxer
{
public:
	FlvMediaMuxer();
	virtual ~FlvMediaMuxer();

	virtual bool open(const UMediaFormat& fmt);

	virtual void close();

	virtual bool isOpen();


	virtual bool getOutFormat(UMediaFormat& fmt);

	virtual bool input(UMediaPacket& pkt);

	virtual void setSink(Sink sink);

    virtual const char* getName();

protected:
	static int flv_onmuxer(void* flv, int type, const void* data, size_t bytes, uint32_t timestamp);
	
	static int flv_write(void* param, const void* buf, int len);

	void onmuxer(int type, const void* data, size_t bytes, uint32_t timestamp);
	int onwrite(const void* buf, int len);


	int getVideoCodecId(int codec);
	int getAudioCodecId(int codec);

private:
	FlvMediaMuxerPrivate*	m_pimp;
	UMediaFormat	m_format;

	TimeShift	m_videoShift;
    TimeShift   m_audioShift;

};

#endif /* FLVMEDIAMUXER_H_ */
